<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>会员列表</title>
		<link rel="stylesheet" href="__OEM__/css/iconfont.css" />
		<link rel="stylesheet" href="__OEM__/css/css.css" />
		<style>
			.empty{top: 83px;}
		</style>
	</head>

	<body>
		{include file="public/header" /}
		<div class="index_conbox">
			<div class="index_content clearfix">
				{include file="public/lefter" /}
				<div class="right">
					<!--右侧内容-->
					<div class="rigtop">
						<span class="title">会员列表</span>
					</div>
					<div class="indrig_con">
						<div class="zizh_conbox" style="padding-top: 20px;">
							<!--选项卡内容开始-->
							<form id="my_form" action="{:url('oem/accounts/user')}" method="post">
								<div class="zizh_con_1">
									<div class="shxx_row chax_row  clearfix">
										{if $Think.session.user_level==1}
										<div class="left" style="width: 100px;">省级代理商：</div>
										<div class="right clearfix">
											<div id="htselect">	
											<select name="agency_id" id="agency_id">
												<option value="">全部</option>
												{volist name="province" id="vo"}
													<option value="{$vo.id}" {if $vo.id==$agency_id}selected{/if}>{$vo.user_name}</option>
												{/volist}
											</select>
											</div>
										</div>
										{/if}
										{if $Think.session.user_level==1 || $Think.session.user_level==4}
										<div class="left" style="width: 100px;">市级代理商：</div>
							            <div class="right clearfix">
											<div id="htselect">	
											<select name="agency_id1" id="agency_id1">
												<option value="">全部</option>
												{volist name="agency" id="str"}
													<option value="{$str.id}" {if $str.id==$agency_id1}selected{/if}>{$str.user_name}</option>
												{/volist}
											</select>
											</div>
										</div>
										{/if}
										{if $Think.session.user_level==1 || $Think.session.user_level==4}
											<div class="left" style="margin-left: 10px;">区域运营商ID：</div>
											<div class="right clearfix">
												<input type="text" name="agency_id2" placeholder="请输入运营商ID" class="chax_input" value="{$agency_id2}"/>
											</div>
										{/if}
										{if $Think.session.user_level==2}
											<div class="left"  style="margin-left: 10px;">运营商：</div>
											<div class="right clearfix">
												<div id="htselect">
													<select name="agency_id2" id="agency_id2">
															<option value="">全部</option>
															{volist name="area" id="ts"}
															<option {if $agency_id2==$ts.id} selected {/if} value="{$ts.id}">{$ts.user_name}</option>
															{/volist}
													</select>
												</div>
											</div>
										{/if}
										<div class="left"  style="margin-left: 10px;">商家：</div>
										<div class="right clearfix">
											<input type="text" name="agent_id" id="agent_id" value="{$agent_id}" placeholder="商家ID" class="chax_input" />
										</div>
										<div class="left"  style="margin-left: 10px;">会员手机号：</div>
										<div class="right clearfix">
											<input type="text" name="mobile" value="{$mobile}" id="mobile" placeholder="手机号码" class="chax_input" />
										</div>
										<div class="left"  style="margin-left: 10px;">会员编号：</div>
										<div class="right clearfix">
											<input style="width: 98px;" type="text" name="user_no" value="{$user_no}" id="user_no" placeholder="会员id" class="chax_input" />
										</div>
										<button type="submit" class="htcxbtn">查询</button>
								</div>
							</form>
							<div class="chax_jiegbt clearfix">
								<div class="chax_jieg">总计：{$list->total();}个</div>
								<div class="chax_xzbtnbox">
									<a href="javascript:;" onclick="check()"><i class="iconfont icon-download"></i>会员下载</a>
								</div>
							</div>
							<div class="chax_conbox">
								<div class="chax_jiegnr">
									<table class="zizh_table1 zizh_table2">
										<thead>
											<tr>
												<th style="width:2%;">编号</th>
												<th style="width:8%;">手机号|昵称</th> 
												<!-- <th style="width:11%;">区域运营商</th>  -->
												<th style="width:8%;">推荐人|昵称</th>
												<th style="width:11%;">商家</th>
												<th style="width:5%;">余额</th>
												<th style="width:7%;">鼓励金</th>
												<th style="width:5%;">推广数</th>
												<th style="width:7%;">累计充值</th>
												<th style="width:6%;">状态</th>
												<th style="width:6%;">来源方式</th>
												<th style="width:6%;">来源种类</th>
												<th style="width:10%;">注册时间</th>
												<th style="width:10%;">操作</th>
											</tr>
										</thead>
										<tbody id="tbody">
											{volist name="list" id="vo" empty="$empty"}
											<tr>
												<td>{$vo.id}</td>
												<td>{$vo.mobile}<p>{$vo.nickname}</p></td> 
												<!-- <td>{$vo.city_name}</td> -->
												<td>{$vo.tmobile}<p>{$vo.tnickname}</p></td>
												<td>{$vo.agent_name}</td>
												<td><a href="javascript:;log_user('{$vo.id}')">{$vo['balance']}</a></td>
												<td><a href="javascript:;show_score({$vo['id']})">{$vo['score']}</a></td>
												<td>
													<a href="javascript:;show_member({$vo['id']})">
														{$vo.count?$vo.count : 0}
													</a>
												</td>
												<td>￥{$vo.cz?$vo.cz : 0}</td>
												<td>
												{if $vo.status==1}
												正常
												{else /}
												冻结 
												{/if}
												</td>
												<td><?php switch($vo['reg_type']){
													case 1:
														echo "关注";
														break;
													case 2:
														echo "收款码";
														break;
													case 3:
														echo "红包";
														break;
													case 4:
														echo "购券码";
														break;
													case 5:
														echo "被扫付款";
														break;
													case 6:
														echo "单商品码";
														break;
												}
												?>
												
												</td>
												<td>
												<?php 
													if($vo['openid']){ echo "微信"; }
													if($vo['alipay_id']){ echo "支付宝"; }
												?>
												</td>													
												<td>{$vo.add_time}</td>
												
												<td style="text-align: center">	
														{if $vo.status == 1}
														<a href="javascript:;" onclick="caozuo('{$vo.id}','2')" >冻结</a>
														{else/}
														<a href="javascript:;" onclick="caozuo('{$vo.id}','1')" class="green">激活</a>
														{/if}
														
														<a href="javascript:;" onclick="setuser('{$vo.id}')"  style="background-color:peru;">层级</a>
														
														{if $Think.session.user_level==1}
														<a href="javascript:;" onclick="shixiao('{$vo.id}')" class="green">失效 </a>
														{/if} 
												</td>
												
											</tr>
											{/volist}
										</tbody>
									</table>
									<div class="fenye" style="display: block;">
										{$list->render()}
									</div>
								</div>
							</div>
							</div>
						</div>

					</div>
				</div>
			</div>
		</div>
		{include file="public/footer" /}

	</body>

</html>
<script>
function check() {
	var mobile = $('#mobile').val();
	var user_no = $('#user_no').val();
	var agency_id2 = $('#agency_id2').val();
	var agent_id = $('#agent_id').val();
	var agency_id1 = $('#agency_id1').val();
	window.location.href = "/oem/accounts/user_dcxml.html?mobile="+mobile+ "&user_no=" + user_no+ "&ch_city=" + agency_id2+ "&agent_id=" + agent_id+ "&yys=" + agency_id1;
}
/*操作*/
function shixiao(id) {

	layer.confirm('确定当前操作？', {
		btn: ['确定', '取消'] //按钮
	}, function() {
		$.ajax({
			url: "{:url('accounts/user_sx')}",
			data: {
				id:id
			},
			dataType: 'json',
			success: function(data) {
				layer.msg("操作成功", {
					icon: 1,
					time: 1000
				}, function() {
					location.href = "{:url('accounts/user')}";
				});
			}
		})
	})
}

/*操作*/
function caozuo(id,status) {
	var msg='';
	if(status==2){
		msg='冻结';
	}else{
		msg='激活';
	}
	layer.confirm('您确定要'+msg+'吗？', {
		btn: ['确定', '取消'] //按钮
	}, function() {
		$.ajax({
			url: "{:url('accounts/user_status')}",
			data: {
				id:id,
				status:status
			},
			dataType: 'json',
			success: function(data) {
				layer.msg("成功", {
					icon: 1,
					time: 1000
				}, function() {
					location.href = "{:url('accounts/user')}";
				});
			}
		})
	})
}

function show_user(id) {
	var url = 'show_user?id=' + id;
	layer.open({
		type: 2,
		title: '会员详情',
		shadeClose: true,
		shade: 0.8,
		area: ['500px', '500px'],
		content: [url]
	});
}
 
 //余额记录
 function log_user(id){
			var show_url = "{:url('accounts/log_user')}"+'?id='+id;
			layer.open({
				type: 2,
				title: '余额记录',
				shadeClose: true,
				shade: 0.8,
				area: ['900px', '730px'],
				content: show_url
			});
	}

		function show_score(id){
			var show_url = "{:url('accounts/show_score')}"+'?type=3&id='+id;
			layer.open({
				type: 2,
				title: '鼓励金记录',
				shadeClose: true,
				shade: 0.8,
				area: ['775px', '700px'],
				content: show_url
			});
		}

		function show_member(id){
			var show_url = "{:url('accounts/show_user_member')}"+'?id='+id;
			layer.open({
				type: 2,
				title: '成员列表',
				shadeClose: true,
				shade: 0.8,
				area: ['800px', '730px'],
				content: show_url
			});
		}
		
		
		/*开通分享*/
	function share(id) {
		layer.confirm('您确定要开通分享吗？', {
			btn: ['确定', '取消'] //按钮
		}, function() {
			$.ajax({
				url: "{:url('accounts/is_share')}",
				data: {
					id:id,
				},
				dataType: 'json',
				success: function(data) {
					layer.msg("成功", {
						icon: 1,
						time: 1000
					}, function() {
						location.href = "{:url('accounts/user')}";
					});
				}
			})
		})
	}

    //编辑
    function setuser(id){
		var url = 'edit_user?id=' + id;
		layer.open({
			type: 2,
			title: '编辑',
			shadeClose: true,
			shade: 0.8,
			area: ['600px', '480px'],
			content: [url]
		});
    }

</script>